/**
 *
 */
package 算法;

import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @Title: 删除重复字符 Goods ->Gods
 * @author zhoujie
 * @date 2018年6月4日 下午3:00:35
 */
public class RemoveDuplicate {
    public static void main(String[] args) {
        System.out.println(removeDuplicate("abcaabcd"));
    }

    public static String removeDuplicate(String str) {
        if (Objects.isNull(str)) return "";
        Set<String> sm = new LinkedHashSet<>(str.length());
        for (int i = 0; i < str.length(); i++) {
            sm.add(String.valueOf(str.charAt(i)));
        }
        return sm.stream().collect(Collectors.joining(""));
    }
}
